package com.yupao.model.enums;

/**
 * 用户身份
 */
public enum UserRoleEnum {

    USER("普通用户", "user"),
    ADMIN("管理员", "admin"),
    BAN("被封用户", "ban");

    private final String name;
    private final String value;

    UserRoleEnum(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    public static UserRoleEnum getByEnumValue(String value) {
        if (value == null) {
            return null;
        }

        for (UserRoleEnum userRoleEnum : UserRoleEnum.values()) {
            if (userRoleEnum.value.equals(value)) {
                return userRoleEnum;
            }
        }
        return null;
    }
}
